<template>
	<view class="flex-col zhuyuanriqindan">
		<view class="flex-row wrapper">

			<view class="flex-col flex-row wraper-col">
				<view class="flex-row box">
					<view class="u-line-1 text" style="width: 90px;">{{xz.thePatient.name}}</view>
					<view v-if="xz.status=='住院中'">
						<u-tag text="住院中" shape="circle"></u-tag>
					</view>
					<view v-if="xz.status=='已出院'">
						<u-tag text=已出院 shape="circle"></u-tag>
					</view>
				</view>
				<view class="u-line-1 text-two">{{xz.admissionNumber}}</view>
			</view>


			<!-- <u-tag class="tag" text="父母" shape="circle"></u-tag> -->

			<!-- 切换就诊人开始 -->
			<view style="float: left;margin-left: 80px;width: 65px;height: 65px;" @click="show = true">
				<uni-icons type="staff-filled" size="40" color="#006eff"></uni-icons>
				<br>
				<!-- <u-icon class="" name="coupon" type="staff-filled" :size="40" color="#006eff"></u-icon> -->
				<text style="float: left;margin-left: -15px;color: #bfc2c6;">切换住院人</text>
			</view>
			<!-- 切换就诊人结束 -->
			<!-- <u-icon class="icon-coupon" name="coupon" :size="40" label="切换就诊人" :label-size="24" label-pos="bottom"></u-icon> -->
			<!-- <u-tag class="tag-two" text="tag标签"></u-tag> -->
		</view>
		<!-- 		<view class="flex-col wrapper-two">
			<view class="u-line-1 text-three">日花费金额：</view>
			<view class="u-line-1 text-four">￥{{record.money}}</view>
		</view> -->
		<view style="width: 100%;height: 30px;"></view>
		<!--      <u-button class="button" type="success" size="mini">
            按钮
        </u-button> -->


		<view class="flex-col wrapper-two" style="margin-bottom: 40px;" v-for="(r, index) in recordjlVoL"
			@click="onClickxq(r)">
			<view class="flex-row wraper-row">
				<view class="u-line-1 text-three"></view>

				<view v-if="r.status=='已出院	'">
					<u-tag class="tag-three" text="已出院" type="success" shape="circle"></u-tag>
				</view>
				<view v-if="r.status=='住院中'">
					<u-tag text="住院中" shape="circle"></u-tag>
				</view>
			</view>
			<view class="flex-row wraper-row-two">
				<view class="u-line-1 text-four">住院人：</view>
				<view class="u-line-1 text-five">{{r.name}}</view>
			</view>
			<view class="flex-row wraper-row-three">
				<view class="u-line-1 text-six">入院日期：</view>
				<view class="flex-row box-two">
					<view class="u-line-1 text-seven" style="width: 200px;">{{r.hospitalizedTime}}</view>
					<view class="u-line-1 text-eight" style="size: 22px;">￥{{r.money}}</view>
				</view>
			</view>
			<view class="flex-row wraper-row-four">
				<view class="u-line-1 text-nine">出院日期：</view>
				<view class="u-line-1 text-ten" style="width: 140px;margin-left: 19px;">{{r.leavehospitalTime}}</view>
			</view>
		</view>
		<view v-if="recordjlVoL==null" class="flex-col wrapper-three">
			<view  style="height: 250px;width: 100%;">
				<view style="height: 30px;font-size: 16px;color: #966ed5;margin:108px;">
					<text>没有住院记录哦！</text>
				</view>
			</view>
		</view>




		<u-popup :show="show" @close="close" @open="open">
			<view>
				<view style="width: 100%;height: 50px;">
					<text style="float: left;;margin:15px 0px 0px 115px;color:#000;font-size: 26px;">请选择住院人</text>
				</view>


				<view v-for="(item, index) in inpatients" :key="item.id" :ref="'item'+index" @click="onClick(item)"
					style="float: left;margin:0px 0px 0px 5px;border-bottom:2px solid #f2f2f2;margin-top: 5px;">
					<view style="width: 100%;height: 65px;">
						<view style="font-size: 24px;float: left;margin:0px 0px 0px 35px;width: 100px;">
							<text>{{item.thePatient.name}}</text>
						</view>
						<view v-if="item.status=='住院中'"
							style="width: 66px;height: 26px;float: left;;margin:-2px 0px 0px 45px;">
							<u-tag text="住院中" shape="circle"></u-tag>
						</view>

						<view v-if="item.status=='已出院'"
							style="width: 66px;height: 26px;float: left;;margin:-2px 0px 0px 45px;">
							<u-tag text="已出院" shape="circle"></u-tag>
						</view>
						<view style="font-size: 19px;color: #e9dfd7;float: left;;margin:32px 0px 0px -205px;">
							<text>{{item.admissionNumber}}</text>
						</view>
						<view class="tb1">
							<u-icon name="arrow-right" color="#2979ff" size="22"></u-icon>
						</view>
					</view>
				</view>





				<!-- <view>
					<u-button class="button1" type="success" shape="circle">
						添加与会人
					</u-button>
				</view> -->
				<view style="clear: both;background-color: #f2f2f2;width: 100%;height: 20px;"></view>

				<view style="height: 60px;" @click="close">
					<u-button class="button1" style="color: #a7a19c;" type="success" shape="circle">
						取消
					</u-button>
				</view>
			</view>
		</u-popup>




	</view>
</template>


<script>
	export default {
		data() {
			return {
				datetimerange: [],
				show: false,
				inpatients: {},
				xz: {
					status: null,
					admissionNumber: null,
					thePatient: {}
				},
				record: {
					money: 0,
					d: {}
				},
				recordjlVoL: null,
			}
		},
		onLoad() {
			//获取当前登录用户的id
			const user = uni.getStorageSync("user")
			// console.log(user)
			this.userId = user.id
			// console.log(this.userId)

			//调用方法---（查看当前登录下的所有住院人）
			this.findAllzhuyuanren()
		},
		methods: {
			//查看当前登录下的所有住院人
			findAllzhuyuanren() {
				uni.request({
					url: "http://localhost:9000/user/user/inpatient/inpatientUserId/" + this.userId,
					method: "GET",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.inpatients = res.data.data.inpatients
							this.xz = this.inpatients[0]
							console.log(this.inpatients)
							console.log("xz为：：：：" + this.xz)
							console.log("id为：：：：" + this.xz.id)
							//调用方法 --- (根据住院人的id查询该住院人的住院记录和花费)
							// this.findAllyp()
							this.findAllhf()



						}
					}
				})
			},

			// 根据住院人的id查询该住院人的住院记录和花费
			findAllhf() {
				console.log("最后的id：：：" + this.xz.id)
				uni.request({
					url: "http://localhost:9000/record/record/record/selectjlByInpatientID/" + this.xz.id,
					method: "GET",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.recordjlVoL = res.data.data.recordjlVo
							console.log("ddd")
							console.log(res.data.data.recordjlVo)
							if (res.data.data.recordjlVo.length == 0) {
								console.log("zoukong!!!!!" + this.recordjlVoL)
								console.log(this.recordjlVoL)
								this.recordjlVoL = null
							}
						}
					}

				})
			},


			findAllyp() {
				console.log("最后的id：：：" + this.xz.id)
				uni.request({
					url: "http://localhost:9000/record/record/record/selectByInpatientID/" + this.xz.id,
					method: "GET",
					success: (res) => {
						// console.log(res)
						if (res.data.code == 20000) {
							this.record = res.data.data.record
							if (res.data.data.record == null) {
								console.log("zoukong!!!!!")
								this.record = {
									money: 0,
									d: {}
								}
							}
							console.log(this.record)
						}
					}

				})
			},


			onClick(item) {
				this.xz = item
				this.show = false
				//根据住院人的id查询该住院人的住院记录和花费
				this.findAllhf()
			},
			onClickxq(item){
				uni.navigateTo({
					url: "./feiyongxiangqing?drugRecordSerialNumber=" +item.drugRecordSerialNumber,
				})
			},

			open() {
				// console.log('open');
			},
			close() {
				this.show = false
				// console.log('close');
			}
		}
	}
</script>
<style lang="scss" scoped>
	.button1 {
		padding: 25px 0px 25px 0px;
		font-size: 18px;
		background-color: #ffffff;
		color: #3875f2;
		border-color: #f8f8f8;
		border-radius: 0px;
	}

	.tb1 {
		float: left;
		margin: -32px 0px 0px 350px;
	}


	/** 全局样式-开始,建议放在公共css样式文件中,比如common.css 或app.vue文件 */

	html,
	body {
		margin: 0;
		width: 100%;
		height: 100%;
		font-size: 16px
	}

	view,
	text,
	image {
		position: relative;
		box-sizing: border-box;
		flex-shrink: 0;
	}

	.flex-col {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
	}

	.flex-row {
		display: flex;
		align-items: flex-start;
	}

	.flex-col .flex-row {
		width: 100%
	}

	/** 全局样式-结束*/

	.zhuyuanriqindan {
		height: 896px;
		padding: 32px 0px 0px 11px;
		border-width: 2px;
		border-top-color: #f5f5f6;
		border-right-color: #f8f8f8;
		border-bottom-color: #f8f8f8;
		border-left-color: #f8f8f8;
		background: #ffffff;
		box-shadow: 2px 2px 2px #F56C6C;

		.wrapper {
			width: 388px;
			height: 102px;
			margin-bottom: 24px;
			padding: 16px 0px 0px 20px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f2f6fc;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f2f6fc;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f2f6fc;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f2f6fc;
			background: rgba(245, 249, 255, 1);
			box-shadow: 2px 2px 2px #b9dcff;

			.wraper-col {
				width: 179px;
				margin-right: 16px;

				.box {
					width: 179px;
					justify-content: space-between;
					margin-bottom: 6px;

					.text {
						width: 53px;
						margin-top: 2px;
						font-size: 22px;
					}
				}

				.text-two {
					width: 170px;
					font-size: 14px;
				}
			}

			.tag {
				margin-right: 46px;
			}

			.icon-coupon {
				width: 60px;
				margin-top: 15px;
			}

			.tag-two {
				top: -34920px;
				left: -13479px;
				position: absolute;
			}
		}

		.wrapper-two {
			width: 387px;
			height: 176px;
			margin: -20px 0px 10px 2px;
			padding: 23px 0px 24px 16px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f2f6fc;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f2f6fc;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f2f6fc;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f2f6fc;
			background: rgba(255, 255, 255, 1);
			box-shadow: 2px 2px 2px #b9dcff;

			.wraper-row {
				width: 360.5px;
				margin-bottom: 19px;

				.text-three {
					width: 92px;
					margin-right: 141px;
					font-size: 16px;
				}

				.tag-three {
					margin-right: 7px;
				}
			}

			.wraper-row-two {
				width: 165.5px;
				justify-content: space-between;
				margin: 0px 0px 10px 10px;

				.text-four {
					width: 68px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.text-five {
					width: 68px;
					font-size: 14px;
					color: #aaaaaa;
				}
			}

			.wraper-row-three {
				width: 311px;
				justify-content: space-between;
				margin: 0px 0px 5px 10px;

				.text-six {
					width: 78px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.box-two {
					width: 214px;

					.text-seven {
						width: 107px;
						margin-right: -5px;
						font-size: 14px;
						color: #aaaaaa;
					}

					.text-eight {
						width: 112px;
						margin-top: 4px;
						font-size: 14px;
						color: rgba(244, 99, 99, 1);
					}
				}
			}

			.wraper-row-four {
				width: 204px;
				justify-content: space-between;
				margin: 0.5px 0px 0px 10px;

				.text-nine {
					width: 78px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.text-ten {
					width: 107px;
					font-size: 14px;
					color: #aaaaaa;
				}
			}
		}

		.button {
			width: 131px;
			margin: 0px 0px 9px 2px;
		}

		.wrapper-three {
			width: 387px;
			// height: 458px;//不设置高，达到动态效果
			margin-left: 2px;
			padding-top: 23px;
			border-top-width: 2px;
			border-top-style: solid;
			border-top-color: #f2f6fc;
			border-right-width: 2px;
			border-right-style: solid;
			border-right-color: #f2f6fc;
			border-bottom-width: 2px;
			border-bottom-style: solid;
			border-bottom-color: #f2f6fc;
			border-left-width: 2px;
			border-left-style: solid;
			border-left-color: #f2f6fc;
			background: rgba(255, 255, 255, 1);
			box-shadow: 2px 2px 2px #b9dcff;

			.text-five {
				width: 92px;
				margin: 0px 0px 9px 16px;
				font-size: 16px;
				color: #aaaaaa;
			}

			.line {
				width: 100%;
				border-width: 2px;
				border-style: solid;
				border-color: #f2f2f2;
			}

			.wraper-row {
				width: 387px;
				margin-bottom: 10px;
				padding: 12px 0px 8px 3.5px;

				.box-two {
					width: 369px;
					margin-left: 11px;

					.box-col {
						width: 121.5px;
						margin-right: 13px;

						.text-six {
							width: 119px;
							margin-bottom: 4px;
							font-size: 14px;
							color: rgba(0, 0, 0, 1);
						}

						.container {
							width: 121.5px;

							.text-seven {
								width: 78px;
								margin-bottom: -20px;
								font-size: 12px;
								color: #aaaaaa;
							}

							.text-eight {
								width: 72px;
								margin-left: 49px;
								font-size: 14px;
								color: #aaaaaa;
							}
						}
					}

					.text-nine {
						width: 40px;
						margin: 24px 1px 0px 0px;
						font-size: 12px;
						color: #aaaaaa;
					}

					.text-ten {
						width: 27px;
						margin: 24px 54px 0px 0px;
						font-size: 14px;
						color: #aaaaaa;
					}

					.text-eleven {
						width: 112px;
						margin-top: 10px;
						font-size: 16px;
						color: rgba(244, 99, 99, 1);
					}
				}

				.line-two {
					width: 383px;
					border-width: 2px;
					border-style: solid;
					border-color: #f2f2f2;
				}
			}


			.wrapper-two {
				width: 387px;
				height: 176px;
				margin: -20px 0px 10px 2px;
				padding: 23px 0px 24px 16px;
				border-top-width: 2px;
				border-top-style: solid;
				border-top-color: #f2f6fc;
				border-right-width: 2px;
				border-right-style: solid;
				border-right-color: #f2f6fc;
				border-bottom-width: 2px;
				border-bottom-style: solid;
				border-bottom-color: #f2f6fc;
				border-left-width: 2px;
				border-left-style: solid;
				border-left-color: #f2f6fc;
				background: rgba(255, 255, 255, 1);
				box-shadow: 2px 2px 2px #b9dcff;

				.wraper-row {
					width: 360.5px;
					margin-bottom: 19px;

					.text-three {
						width: 92px;
						margin-right: 141px;
						font-size: 16px;
					}

					.tag-three {
						margin-right: 7px;
					}
				}



				.wraper-row-three {
					width: 311px;
					justify-content: space-between;
					margin: 0px 0px 5px 10px;

					.text-six {
						width: 78px;
						font-size: 14px;
						color: #aaaaaa;
					}

					.box-two {
						width: 214px;

						.text-seven {
							width: 107px;
							margin-right: -5px;
							font-size: 14px;
							color: #aaaaaa;
						}

						.text-eight {
							width: 112px;
							margin-top: 4px;
							font-size: 14px;
							color: rgba(244, 99, 99, 1);
						}
					}
				}

				.wraper-row-four {
					width: 204px;
					justify-content: space-between;
					margin: 0.5px 0px 0px 10px;

					.text-nine {
						width: 78px;
						font-size: 14px;
						color: #aaaaaa;
					}

					.text-ten {
						width: 107px;
						font-size: 14px;
						color: #aaaaaa;
					}
				}
			}



			.wraper-row-two {
				width: 387px;
				padding: 12px 0px 8px 3.5px;

				.text-twelve {
					width: 119px;
					margin: 0px 0px -9px 11px;
					font-size: 14px;
					color: rgba(0, 0, 0, 1);
				}

				.text-thirteen {
					width: 112px;
					margin: 0px 0px -6px 268px;
					font-size: 16px;
					color: rgba(244, 99, 99, 1);
				}

				.text-fourteen {
					width: 78px;
					margin: 0px 0px -20px 11px;
					font-size: 12px;
					color: #aaaaaa;
				}

				.text-fifteen {
					width: 40px;
					margin: 0px 0px -19px 146px;
					font-size: 12px;
					color: #aaaaaa;
				}

				.text-sixteen {
					width: 72px;
					margin: 0px 0px -19px 61px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.text-seventeen {
					width: 27px;
					margin: 0px 0px 2px 187px;
					font-size: 14px;
					color: #aaaaaa;
				}

				.line-three {
					width: 383px;
					border-width: 2px;
					border-style: solid;
					border-color: #f2f2f2;
				}
			}
		}
	}
</style>
